<template>
  <!-- 头部盒子 -->

  <div class="header">
    <!-- 标题区域 -->

    <div class="lnner-header">
      <div>
        <h1>欢迎使用《云餐厅》</h1>
        <h2>注册</h2>
        <el-form
          :rules="rules"
          class="login-form"
          ref="form"
          :model="loginform"
        >
          <el-form-item prop="account">
            <el-input
              placeholder="请输入账号"
              type="text"
              v-model="loginform.account"
              prefix-icon="el-icon-user"
            ></el-input>
          </el-form-item>

          <el-form-item prop="password">
            <el-input
              placeholder="请输入密码"
              type="password"
              v-model="loginform.password"
              prefix-icon="el-icon-circle-check"
            ></el-input>
          </el-form-item>
          <div class="footer">
            <el-form-item style="text-aling: center">
              <el-button type="danger" style="width: 30%" @click="back"
                >返回</el-button
              >
              <el-button type="primary" style="width: 30%" @click="zhuce"
                >注册</el-button
              >
            </el-form-item>
          </div>
        </el-form>
      </div>
    </div>
  </div>
</template>
  
  
  
  <script>
import axios from "axios";
export default {
  data() {
    return {
      // 账号密码
      loginform: {
        account: "",
        password: "",
      },
      // 账号密码-规则
      rules: {
        account: [{ required: true, message: "请输入用户名", trigger: "blur" }],
        password: [{ required: true, message: "请输入密码", trigger: "blur" }],
      },
    };
  },

  methods: {
    back() {
      this.$router.push("/login");
    },
    async zhuce() {
      var name = this.loginform.account;
      var password = this.loginform.password;

      const { data: res } = await axios.post("/admin/regiser", {
        name: name,
        password: password,
      });
      console.log(res);
      if (res.code !== 200) {
        this.$message.error(res.msg);
        return;
      }
      // // 成功后跳转
      this.$message.success(res.msg);
      this.$router.push("/login");
    },
  },
  created() {},
};
</script>
  
  
  
  <style scoped>
.email_button {
  position: absolute;
  top: 0px;
  right: 0px;
  padding: 13px;
}
.forget {
  height: 0;
}

.forget a {
  text-decoration: none;
  color: #fff;
  float: right;
}

.header {
  position: relative;
  background: linear-gradient(60deg, rgb(191 255 98) 0%, rgb(255 179 0) 100%);
  color: rgb(255, 255, 255);
}

.lnner-header {
  height: 930px;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

h1 {
  text-align: center;
  font-family: "Lato", "sans-serif";
  font-weight: 300;
  /* font-spacing:2px; */
  font-size: 48px;
}

h2 {
  text-align: center;
  font-family: "Lato", "sans-serif";
  font-weight: 300;
  /* font-spacing:2px; */
  font-size: 28px;
}
.people {
  margin: 0 auto;
  width: 25%;
}
.footer {
  text-align: center;
}
.login-form {
  margin: 0 auto;
  width: 300px;
  padding-top: 30px;
}

.el-input__inner {
  background-color: rgba(255, 255, 255, 0.7);
  border-radius: 0;
  border: 1px solid #0094ff;
  color: rgba(0, 0, 0, 0.7);
}

.el-input__inner::placeholder {
  color: rgba(0, 0, 0, 0.3);
}

.el-button {
  border-radius: 4px;
}
</style>
  